<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script>
        (function () {
            if (window.screen.width >= 812) {
                document.querySelector('html').style.fontSize = '82px';
                return
            }
            document.querySelector('html').style.fontSize = window.screen.width / 10 + 'px'
        }())
    </script>
    <title>站长的智慧生活</title>
    <link rel="stylesheet" href="../style/zxsh_1012/style.css">
</head>

<body>
    <div class="main">
        <div class="title-1"></div>
        <div class="title-2"></div>
        <div class="title-3"></div>
        <ul class="nav">
            <li>个护化妆</li>
            <li class="cur ml30">家居家纺及厨具</li>
        </ul>
        <div class="container">
        </div>
        <ul class="nav">
            <li class="cur">个护化妆</li>
            <li class="ml30">家居家纺及厨具</li>
        </ul>
        <div class="container">
        </div>
        <div class="back-top"></div>
    </div>

    <!-- template start -->
    <script type="text/html" id="card-tpl">
        <img src="{{pic}}" alt="">
        <p>{{name}}</p>
        <div><div>原价:<del>{{price_on_tag}}元</del></div> <p>购买价<span>{{discountPrice}}</span>元</p></div>
        <span>立即购买</span>
    </script>
    <script type="text/html" id="ctx-tpl">
        {{each $data}}
            <a class="card C_J_good" href="javascript:;"></a>
        {{/each}}
    </script>
    <!-- template end -->    
</body>
<script src="../../js/jquery-1.8.3.min.js"></script>
<script src="../../js/art-template.js"></script>
<script src="../../js/login.js"></script>
<script src="../../js/model.js"></script>
<script src="../../js/model-citizen.js"></script>
<script>
    (function($,template){
        var info = [
            [139087,84246,41046,140252,136653,139917,146240,146163,146176,142626,118759,124251,146351,146346,146348,135409,134003,122956,112800,112805,112801],
            [142103,143374,142394,146228,141034,146445,142137,121947,138897,147503,147501,142618,140953,140362,139251,144397,135812,129126,140179,136297,115581]
    ]

        function getData(id, idx, index) {
            $.ajax({
                url: 'http://www.cjwsc.com/qcwdProduct/getProductByIds',
                data: {
                    ids: id,
                    business_type: 10,
                    client_type: 1
                },
                dataType: "jsonp",
                jsonp: 'jsonpcallback',
                success: function (res) {
                    var href = 'http://www.cjwsc.com/item/' + id + '.html';
                    res.msg[0].index = idx + 1;
                    res.msg[0].pic = res.msg[0].pic.replace('240_240', '800_800')
                    var element = index ? $('.container').eq(index).find('.card').eq(idx) : $('.card').eq(idx);
                    element.html(template('card-tpl', res.msg[0])).attr('data-id', id);
                    if (res.msg[0].stock_num == 0 || res.msg[0].status == 2) element.addClass('masker')
                        .removeAttr('href');
                }
            })
        }

        function setData(info){
            for(var i=0,len=info.length;i<len;i++){
                $('.container').eq(i).html(template('ctx-tpl',info[i]))
                for(var j=0,leng=info[i].length;j<leng;j++){
                    getData(info[i][j],j,i)
                }
            }
        }
        setData(info);

        $('.nav').on('click','li',function(){
            var $this = $(this);
            $('html,body').animate({
                scrollTop: $('.nav').eq($this.index()).offset().top
            }, 500)
        })

        $('.back-top').on('click', function () {
            $('html,body').animate({
                scrollTop: 0
            }, 500)
        })

    })($,template)
</script>
</html>



